package com.hrp.hrpdao;

import com.hrp.domain.TransportRecord;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.mapping.StatementType;

import java.util.List;
import java.util.Map;

/**
 * Created by Administrator on 2019-04-29.
 */
@Mapper
public interface TransportRecordQueryDao {


    @Select("select count(*) total from UIMSS_TRANSPORTRECORD")
    Integer getTotalCount();

    @Select("<script>"
            + " select * from ( select *,ROW_NUMBER() over(order by id) row from UIMSS_TRANSPORTRECORD ) T where row in "
            + "<foreach item='item' index='index' collection='strList' open='(' separator=',' close=')'>"
            + "#{item}"
            + "</foreach>"
            + " order by  ${sort} ${order}"
            + "</script>")
    List<TransportRecord> getTransportRecordByPage(@Param("strList") List<Integer> strList,@Param("sort") String sort,@Param("order") String order );



    /**
     * 调用存储过程，获取采购单号
     * @param params={storeCode=门店编号,tsCode生成单号的类型}
     * @return params={purchaseOrderNumber=采购单号}
     *     @Select({ "call textss(#{storeCode,mode=IN,jdbcType=VARCHAR},"
    + "#{tsCode,mode=IN,jdbcType=VARCHAR},"
    + "#{purchaseOrderNumber,mode=OUT,jdbcType=VARCHAR})" })
     */
//    @Select({ "exe textss(#{strList,mode=IN,jdbcType=VARCHAR},"
//            + "#{sort,mode=IN,jdbcType=VARCHAR}"})
//    @Options(statementType= StatementType.CALLABLE)

    @Options(statementType=StatementType.CALLABLE)
    @Select({ "exec usp_uimms_getTransportRecordByPageForProc #{page},#{rows},#{sort},#{order},#{sendTimeKsrq},#{sendTimeJsrq},#{varietiesIdStr},#{supplierIdStr},#{receiverIdStr}" })
    List<Map<String,String>> getTransportRecordByPageForProc(Map<String,String> params);


    @Options(statementType=StatementType.CALLABLE)
    @Select({ "exec usp_uimms_getTransportRecordByPageForProc_Summary #{page},#{rows},#{sort},#{order},#{sendTimeKsrq},#{sendTimeJsrq},#{varietiesIdStr},#{supplierIdStr},#{receiverIdStr}" })
    List<Map<String,String>> getTransportRecordByPageSummary(Map<String, String> params);
}
